<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>节点操作</title>
</head>

<body>
    <div id="b">我是div</div>
    <span>我是span</span>
    <ul>
        <li>李昊哲</li>
        <li>刘晓兰</li>
        <li>phoenix</li>
        <li>小兰兰</li>
    </ul>
    <div id="family">
        <div class="father">
            爸爸
            <div class="son">儿子</div>
        </div>
    </div>
</body>

</html>
<script>
    let ul = window.document.querySelector('ul');
    // window.console.log(ul.childNodes);
    let sons = ul.children;
    for (let index = 0; index < sons.length; index++) {
        const element = sons[index];
        window.console.log(element.innerText);
    }
    let lis = window.document.querySelectorAll('li');
    for (let index = 0; index < lis.length; index++) {
        const element = lis[index];
        window.console.log(element.innerText);
    }
    window.console.log(ul.nodeType);
    window.console.log(sons[0].nodeType);
    let father = window.document.querySelector('.father');
    window.console.log(father.children[0].innerText);
    window.console.log(father.childNodes[1]);
    let b = window.document.querySelector('#b');
    window.console.log(b.nextSibling);
    window.console.log(b.nextElementSibling);
    window.console.log(ul.firstElementChild);
    window.console.log(ul.lastElementChild);
</script>